<template>
    <view class="bg-content">
        <u-cell-group v-if="sysUser">
            <u-cell-item title="登录账号" :arrow="toValue('globalVariable.userInfo.allowAlterFields', globalVariable, '').indexOf('username') !== -1"
                         :value="sysUser.username" @click="gotoSetUsernamePage()"
                         :label="toValue('globalVariable.userInfo.allowAlterFields', globalVariable, '').indexOf('username') !== -1 ? '可变更一次' : ''"></u-cell-item>
            <u-cell-item title="修改密码" @click="navigateTo(`/pages/sub/sub1-tabs/tabs/person/setting/setting-alter-password/index`)"></u-cell-item>
            <u-cell-item title="邮箱" :value="sysUser.email ? sysUser.email : '点击设置'"
                         @click="gotoSetEmailPage()"></u-cell-item>
        </u-cell-group>
    </view>
</template>

<script>

    import {toValue} from "@/dev/core/utils/filters.util";

    export default {
        data() {
            return {
                sysUser: null,
            }
        },
        onShow() {
            const _self = this;
            _self.sysUser = this.globalVariable.userInfo;
        },
        methods: {
            gotoSetUsernamePage() {
                if (toValue('globalVariable.userInfo.allowAlterFields', this.globalVariable, '').indexOf('username') !== -1) {
                    this.navigateTo(`/pages/sub/sub1-tabs/tabs/person/setting/setting-alter-username/index`);
                }
            },
            gotoSetEmailPage() {
                if (this.globalVariable.userInfo.email) {
                    this.navigateTo(`/pages/sub/sub1-tabs/tabs/person/setting/setting-my-info/setting-my-info-alter-email-step1/index`);
                } else {
                    // 不存在邮箱，则直接设置新邮箱
                    this.navigateTo(`/pages/sub/sub1-tabs/tabs/person/setting/setting-my-info/setting-my-info-alter-email-step1/setting-my-info-alter-email-step2/index?backPageNum=1`);
                }
            }
        }
    }
</script>

<style lang="scss" scoped>
</style>
